package cn.yunhe.action;

import cn.yunhe.entity.Permission;
import cn.yunhe.entity.Role;
import cn.yunhe.service.PermissionBiz;
import cn.yunhe.util.BaseActionUtil;
import com.opensymphony.xwork2.ModelDriven;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class PermissionAction extends BaseActionUtil implements ModelDriven {

    @Autowired
    @Qualifier(value = "permissionBiz")
    private PermissionBiz permissionBiz;

    private Permission permission;
    List<Permission>permissionList;

    private int rid;

    public String searchByConditions(){
        Map<String,Object>objectMap=new HashMap<>();
        System.out.println("getPflag===="+permission.getPflag());
        System.out.println("rid===="+rid);
        objectMap.put("permission",permission);
        objectMap.put("rid",rid);
        if (rid>0){
            permissionList=permissionBiz.searchByRid(objectMap);
        }else {
            permissionList=permissionBiz.searchByPflag(objectMap);
        }
        System.out.println("size===="+permissionList.size());
        return SUCCESS;
    }


    public PermissionBiz getPermissionBiz() {
        return permissionBiz;
    }

    public void setPermissionBiz(PermissionBiz permissionBiz) {
        this.permissionBiz = permissionBiz;
    }

    public Permission getPermission() {
        return permission;
    }

    public void setPermission(Permission permission) {
        this.permission = permission;
    }

    public List<Permission> getPermissionList() {
        return permissionList;
    }

    public void setPermissionList(List<Permission> permissionList) {
        this.permissionList = permissionList;
    }


    public int getRid() {
        return rid;
    }

    public void setRid(int rid) {
        this.rid = rid;
    }

    @Override
    public Permission getModel() {
        if (permission==null)
            permission=new Permission();
        return permission;
    }
}
